% use fmincon to optimize gearbox size
clear all, clc

% objective function: height of gearbox
f = @(x) (x(1)/x(5) + x(2)/x(5)/2 + x(3)/x(6));

%  linear inequality constraints
A = [0,0,0,0,-1,0;0,0,0,0,0,-1];
b = [6;6];

% no linear equality constraints
Aeq = [ ];
beq = [ ];

% lower bounds
lb = [15,15,15,15,6,6];

% upper bounds
ub = [200,200,200,200,40,40];

options = optimset('LargeScale','off','Display','iter');

% initial guess
x0 = [16, 100, 16, 100, 12, 12];
[x,fval,exitflag,output] = fmincon(f,x0,A,b,Aeq,beq,lb,ub, ...
    'SQPcon',options)
